package com.djakapm.swing.component;

import com.djakapm.swing.common.ContainerFactory;

import javax.swing.*;

public class SpecForSplitPaneView {
    public void can_split_horizontally() {
        SplitPaneView spv = new SplitPaneView();
        spv.splitHorizontally(new JButton("left"),new JButton("right"));
        JFrame frame = ContainerFactory.newFrame("Horizontal Split");
        frame.getContentPane().add(spv);
        frame.setVisible(true);
    }

    public void can_split_vertically(){
        SplitPaneView spv = new SplitPaneView();
        spv.splitVertically(new JButton("top"),new JButton("bottom"));
        JFrame frame = ContainerFactory.newFrame("Vertical Split");
        frame.getContentPane().add(spv);
        frame.setVisible(true);
    }

    public void can_split_at_the_middle_before_shown(){
        SplitPaneView spv = new SplitPaneView();
        spv.splitHorizontally(new JButton("top"),new JButton("bottom"));
        spv.setDividerLocation(0.15);
        JFrame frame = ContainerFactory.newFrame("Vertical Split with Divider Position");
        frame.getContentPane().add(spv);
        frame.setVisible(true);
    }

    public void can_split_horizontally_with_one_touch_expand() {
        SplitPaneView spv = new SplitPaneView();
        spv.splitHorizontally(new JButton("left"),new JButton("right"));
        spv.setOneTouchExpandable(true);
        JFrame frame = ContainerFactory.newFrame("Horizontal Split");
        frame.getContentPane().add(spv);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SpecForSplitPaneView sfspv = new SpecForSplitPaneView();
        sfspv.can_split_horizontally();
        sfspv.can_split_vertically();
        sfspv.can_split_at_the_middle_before_shown();
        sfspv.can_split_horizontally_with_one_touch_expand();
    }
}